package work;

/**
 * @TODO
 * @Author xu
 * 2025/2/24
 */
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;
public class Day3_1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入订票日期：");
        String inputDate = scanner.nextLine();
        LocalDate orderDate = LocalDate.parse(inputDate, DateTimeFormatter.ISO_LOCAL_DATE);
        System.out.print("请输入票价：");
        double ticketPrice = scanner.nextDouble();
        double finalPrice = calculateTicketPrice(orderDate, ticketPrice);
        System.out.printf("应付金额: %.2f 元\n", finalPrice);
        scanner.close();
    }

    private static double calculateTicketPrice(LocalDate orderDate, double ticketPrice) {
        if ((orderDate.isEqual(LocalDate.of(2024, 1, 1)) ||
                orderDate.isEqual(LocalDate.of(2024, 1, 2)) ||
                orderDate.isEqual(LocalDate.of(2024, 1, 3)))) {
            return ticketPrice;
        }
        if ((orderDate.isEqual(LocalDate.of(2024, 5, 1)) ||
                orderDate.isEqual(LocalDate.of(2024, 5, 2)) ||
                orderDate.isEqual(LocalDate.of(2024, 5, 3)))) {
            return ticketPrice;
        }

        if ((orderDate.isEqual(LocalDate.of(2024, 10, 1)) ||
                orderDate.isEqual(LocalDate.of(2024, 10, 2)) ||
                orderDate.isEqual(LocalDate.of(2024, 10, 3)) ||
                orderDate.isEqual(LocalDate.of(2024, 10, 4)) ||
                orderDate.isEqual(LocalDate.of(2024, 10, 5)) ||
                orderDate.isEqual(LocalDate.of(2024, 10, 6)) ||
                orderDate.isEqual(LocalDate.of(2024, 10, 7)))) {
            return ticketPrice;
        }


        return ticketPrice * 0.8;
    }
}


